package servlet_casa;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * Servlet implementation class configuraCasa
 */
@WebServlet("/configuraCasa")
public class configuraCasa extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		RequestDispatcher rd;
		HttpSession session=request.getSession(true);
		bean.Utente utente=(bean.Utente)session.getAttribute("utente");
		
		String nome=request.getParameter("nome");
		String indirizzo=request.getParameter("indirizzo");
		Integer numeroCivico=Integer.parseInt(request.getParameter("numero"));
		Float mq=Float.parseFloat(request.getParameter("mq").replace(",", "."));
		String citta=request.getParameter("citta");
		bean.Casa casa=new bean.Casa(indirizzo,numeroCivico,mq,citta,utente,nome);
		session.setAttribute("casa", casa);
		rd=request.getRequestDispatcher("/configurazioneStanza.jsp");
		rd.forward(request, response);
	}

}
